import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import legacy from "@vitejs/plugin-legacy";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import topLevelAwait from "vite-plugin-top-level-await";
import * as path from "path";

// https://vitejs.dev/config/
export default defineConfig({
  base: "sdzs",
  build: {
    outDir: "sdzs",
  },
  plugins: [
    vue(),
    // legacy({
    //   targets: ["defaults", "not IE 11"],
    // }),
    topLevelAwait({
      promiseExportName: "__tla",
      promiseImportName: (i) => `__tla_${i}`,
    }),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  resolve: {
    alias: {
      "@/": `${path.resolve(__dirname, "src")}/`,
    },
  },
});
